package iso3.pt.action;

import freemarker.template.utility.StringUtil;
import iso3.pt.dao.PtDAO;
import iso3.pt.model.Alumno;
import iso3.pt.model.Asignatura;

import java.util.Map;
import java.util.Set;

import antlr.StringUtils;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

public class VerAlumnos extends ActionSupport implements Preparable {
	
	private PtDAO dao2;
	private Set <Alumno> alumnos;
	private int codAsignatura;
	private Asignatura asig;
	private String tipoLogin;
	private String username;
	private String password;

	
	
	
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getTipoLogin() {
		return tipoLogin;
	}

	public void setTipoLogin(String tipoLogin) {
		this.tipoLogin = tipoLogin;
	}


	public Asignatura getAsig() {
		return asig;
	}

	public void setAsig(Asignatura asig) {
		this.asig = asig;
	}

	public PtDAO getDao2() {
		return dao2;
	}

	public void setDao2(PtDAO dao) {
		this.dao2 = dao;
	}

	public Set<Alumno> getAlumnos() {
		return alumnos;
	}

	public void setAlumnos(Set<Alumno> alumnos) {
		this.alumnos = alumnos;
	}

	public int getCodAsignatura() {
		return codAsignatura;
	}

	public void setCodAsignatura(int codAsignatura) {
		this.codAsignatura = codAsignatura;
	}

	public void prepare() throws Exception {
		System.out.println("entra en prepare");
		dao2= PtDAO.getInstance();		
	}
	
	public String execute(){
		
		
		System.out.println("El codigo es:" +codAsignatura);
		alumnos=dao2.getAlumnos(codAsignatura);
		asig=dao2.getAsignatura(codAsignatura);
		System.out.println("Despues del dao");
		Map<String,Object> session=ActionContext.getContext().getSession();
		tipoLogin= (String)session.get("tipoLogin");
		System.out.println("El tipologin: " + tipoLogin);
		username= (String)session.get("username");
		System.out.println("El username: " + username);
		password= (String)session.get("password");
		session.put("asig", asig);
		ActionContext.getContext().setSession(session);
		return "ok";
	}

	
}
